﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace bankproject
{
    class Model
    {

   //     static string cardNum;
     //   static string PIN;
       
        bool succes;
        static Random r = new Random();
        
         static int cash = r.Next(1, 200000);
        public Model()
        {

          
            succes = false;

        }
        

        public bool login(string _cardNum, string _PIN)
        {
            if (_cardNum.Length >= 4)
            {
                int j = _cardNum.Length - 1;
                int i = _PIN.Length - 1;
                succes = true;
                while (i >= 0)
                {

                    if (_PIN[i] != _cardNum[j])
                    {
                        succes = false;

                        break;
                    }

                    i--;
                    j--;
                }
            }
          
               
            return succes;
        


        }

        public void logout()
        {
         
        }

        public int getBalance()
        {
            return cash;

        }
        public bool takeCash(int amount)
        {
            if (cash - amount > 0)
                succes = true;
            cash = cash - amount;
            return succes;
        }

    }
}
